import { CourseActionsEnum } from '../../../_/vue/store/course'
import axios from '../../../plugins/axios'

export default {
  [CourseActionsEnum.LIST] ({ commit }, params) {
    return axios.get('/courses', { params })
  },
  [CourseActionsEnum.STORE] ({ commit }, payload) {
    // 创建
    return axios.post('/courses', payload)
  },
  [CourseActionsEnum.EDIT] ({ commit }, id) {
    // 请求接口获取信息
    return axios.get(`/courses/${id}`)
  },
  [CourseActionsEnum.SAVE] ({ commit }, payload) {
    // 保存
    return axios.post(`/courses/${payload.id}`, payload.data)
  },
  [CourseActionsEnum.DELETE] ({ commit }, ids) {
    // 请求删除接口
    return axios.delete('/courses', { data: ids })
  },
  [CourseActionsEnum.SELECT] ({ commit }) {
    return axios.get('/courses/select')
  }
}
